package com.hnkywl.sts.action.jhgl;

import com.hnkywl.sts.entity.jhgl.Hkjh;
import com.hnkywl.sts.service.jhgl.HkjhService;
import com.hnkywl.sts.service.organ.GsjgService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: ZHUCHG
 * Date: 13-5-10
 * Time: 上午11:37
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/jhgl/hkjh")
public class HkjhAction extends SimpleActionSupport {
    private Integer year;
    private Integer month;
    private Long gsId;
    private String gsJc;
    private Long bmId;
    private Date date;
    private Hkjh hkjh;
    private HkjhService hkjhService;
    private GsjgService gsjgService;

    @Action("hkjh")
    public String hkjh() {
        date = new Date();
        return SUCCESS;
    }

    @Action("hkjhmx_content")
    public String hkjhmx() {
        gsJc = gsjgService.findGsjgDetail(gsId).getJc();
        return SUCCESS;
    }

    @Action("hkjh_detail")
    public String hkjhDetail() {
        gsJc = gsjgService.findGsjgDetail(gsId).getJc();
        return SUCCESS;
    }

    @Action("save")
    public void save(){
        try{
            hkjhService.save(hkjh);
            renderText("{\"statusCode\":200}");
        } catch (Exception e){
            e.printStackTrace();
            renderText("{\"statusCode\":300,\"message\":\""+e.getMessage()+"\"}");
        }
    }

    @Action("mxList")
    public void mxList(){
        renderJson(hkjhService.findHkjh(gsId,bmId,year,month));
    }

    @Action("hkjhReport")
    public void hkjhReport() {
        renderJson(hkjhService.findHkjhList(gsId,bmId,year,month));
    }

    //========getter setter=========
    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public Integer getMonth() {
        return month;
    }

    public void setMonth(Integer month) {
        this.month = month;
    }

    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public Long getBmId() {
        return bmId;
    }

    public void setBmId(Long bmId) {
        this.bmId = bmId;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Hkjh getHkjh() {
        return hkjh;
    }

    public void setHkjh(Hkjh hkjh) {
        this.hkjh = hkjh;
    }

    public String getGsJc() {
        return gsJc;
    }

    public void setGsJc(String gsJc) {
        this.gsJc = gsJc;
    }

    @Autowired
    public void setHkjhService(HkjhService hkjhService) {
        this.hkjhService = hkjhService;
    }
    @Autowired
    public void setGsjgService(GsjgService gsjgService) {
        this.gsjgService = gsjgService;
    }
}
